package com.lagou.demo.dao;

import com.lagou.demo.pojo.Order;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface OrderDao {

    @Select("select * from c_order")
    List<Order> findAll();

    @Select("select * from c_order where id = #{id}")
    Order getOrderById(String id);

    @Select("select * from c_order where status = #{status}")
    List<Order> getOrderByStatus(Integer status);

    @Insert("insert INTO c_order (id,`status`) VALUES (#{id},#{status})")
    void insertOneOrder(Order order);

    @Update("UPDATE c_order SET `status`=#{status} WHERE id = #{id}")
    void updateOrderStatusById(@Param("id") String id, @Param("status") Integer status);

}
